﻿using HamcoWcs.Models.Common;
using HamcoWcs.Models.ForeEndModels.Basic;
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace HamcoWcs.Contract.ContractForeEnd
{
    /// <summary>
    /// 前端基础接口
    /// </summary>
    public interface IForeEndBaseService
    {
        /// <summary>
        /// 保存更改
        /// </summary>
        /// <returns>如果返回的数量大于0则为真</returns>
        bool Save();
        /// <summary>
        /// 保存更改
        /// </summary>
        /// <returns>如果返回的数量等于count则为真</returns>
        bool Save(int count);
        /// <summary>
        /// 保存更改
        /// </summary>
        /// <returns>如果返回的数量大于0则为真</returns>
        Task<bool> SaveAsync();
        /// <summary>
        /// 保存更改
        /// </summary>
        /// <returns>如果返回的数量等于count则为真</returns>
        Task<bool> SaveAsync(int count);
        ///// <summary>
        ///// 前端添加操作日志
        ///// </summary>
        ///// <param name="userName">操作者Name</param>
        ///// <param name="msg">添加的消息</param>
        ///// <param name="methodName">接口名（默认自动获取）</param>
        //void AddOperationLog(string userName, string msg, [CallerMemberName] string methodName = "");
        /// <summary>
        /// 前端添加系统错误日志
        /// </summary>
        /// <param name="errMsg">错误信息</param>
        /// <param name="ex">捕获的异常</param>
        ForeEndResult AddSystemErrorLog(string errMsg, Exception ex = null);

        /// <summary>
        /// 序列化对象为Json字符
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <param name="t">要序列化的对象</param>
        /// <returns>JsonString</returns>
        string Serialize<T>(T t);
    }
}
